<%--
  Created by IntelliJ IDEA.
  User: kent.lin
  Date: 2019-07-15
  Time: 18:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
<html>
<head>
    <title>add</title>
</head>
<body>
<select id="select1">

</select>
 <script type="text/javascript">
     $(function () {
         $.ajax({
             url:"/findCategory",
             type:"post",
             contentType:"application/json;charset=utf-8",
             dateType:"json",
             success:function (categoryList) {
                 alert(categoryList[0].cname);
                 var html='';
                 $.each(categoryList,function (i, category) {
                     if (category.id == 1) {
                         html+='<option value="'+category.id+'" selected="selected">'+category.cname+'</option>';

                     }else {
                         html+='<option value="'+category.id+'">'+category.cname+'</option>';

                     }
                 })
                 $("#select1").html(html);
             }
         })
     })
 </script>

</body>
</html>
